package com.hkfg.service.impl;

import com.hkfg.dao.MomentDao;
import com.hkfg.dao.UserDao;
import com.hkfg.domain.Moment;
import com.hkfg.service.MomentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;


@Service
public class MomentServiceImpl implements MomentService{
    @Autowired
    private MomentDao momentDao;
    @Autowired
    private UserDao userDao;

    @Override
    public List<Moment> selectUserMoment(int receiverId) {
        return momentDao.selectMomentById(receiverId);
    }

    @Override
    public int buildMoment(Moment moment) {
        if (momentDao.buildMoment(moment.getContent(), moment.getSenderId(), moment.getReceiverId())>0){
            return 1;
        }
        else {
            return 0;
        }
    }

    @Override
    public Moment getMomentById(int id) {
        return momentDao.getMomentById(id);
    }

    @Override
    public int modifyMoment(int id, String content) {
        return momentDao.modifyMoment(id, content);
    }

    @Override
    public int deleteMomentById(int id) {
        if (momentDao.deleteMomentById(id)>0){
            return 1;
        }
        else {
            return 0;
        }
    }
}
